//
// Created by de on 3/31/21.
//

#ifndef FORCEEIGENTEST_GLOBALVAR_H
#define FORCEEIGENTEST_GLOBALVAR_H

#include <ostream>
#include <sstream>
#include "list"
#include "vector"
#include "sqlite_orm/sqlite_orm.h"
#include "log/SqdLoger.h"


const std::string DeviceCodeMessage[] = {"ForceSensorDevOk", "RobotDevConn", "RobotDevEnable", "rosnode_force_bridge",\
                            "rosnode_forceCompensation", "rosnode_PiHapp", "robotDevErr"};

enum ForceCtlStatus{
    Empty=0,
    Run=1,
    Stop=2,
    Reset=3,
    Wait=4,
    Err=5,
    Finish=6,
    Pullfinish=7,
};
enum ErrCode{empty,Ik_Err,Assemble_Err,RbEnableLoss_Err,ForceSensor_Err,Collsion_Err};

struct ErrCodeInfoData{
    ErrCodeInfoData(){
        errCode=empty;
        Err_stringInfo="";
        Err_level=0; //0--没故障　,１－－不可恢复故障　２－－可恢复故障
    }
    ErrCode errCode;
    int Err_level;
    std::string Err_stringInfo;
};

struct ForceDeviceCommCode{
public:
    ForceDeviceCommCode()
    {
        Error_status = false;
    }

    bool Error_status;
    std::vector<long> v_Error;
    int ErrorLevel;
};


struct ForceStateData{
    ForceCtlStatus  status;
    ErrCodeInfoData errCodeInfoData;
    std::string Info;

};

struct VisionMeasure{
    VisionMeasure(){
        Height=0.0;
    }
    double Height;
    long CodeMessage;
};


struct DeviceState2Commu{
public:
    ForceDeviceCommCode ForceCommCode;
    ForceStateData ForceSate;
};

struct WorkResult{
public:

    WorkResult(){}

    WorkResult(int id, double visionDepthBias, double forceConsumerTime, double visionConsumerTime, bool vaild) : id(
            id), VisionDepthBias(visionDepthBias), ForceConsumerTime(forceConsumerTime), VisionConsumerTime(
            visionConsumerTime), Vaild(vaild) {

    }


    friend std::ostream &operator<<(std::ostream &os, const WorkResult &result) {
        os << "id: " << result.id << " VisionDepthBias: " << result.VisionDepthBias << " ForceConsumerTime: "
           << result.ForceConsumerTime << " VisionConsumerTime: " << result.VisionConsumerTime << " Vaild: "
           << result.Vaild << " datetime: " << result.datetime << " ErrorMessage: " << result.ErrorMessage;
        return os;
    }

    std::string to_string()
    {
        std::ostringstream os;
        os << "id: " << id << " VisionDepthBias: " << VisionDepthBias << " ForceConsumerTime: "
           << ForceConsumerTime << " VisionConsumerTime: " << VisionConsumerTime << " Vaild: "
           << Vaild << " datetime: " << datetime << " ErrorMessage: " << ErrorMessage;
        return os.str();
    }


    void setDateTime(std::string datetime){
        this->datetime = datetime;
    }

public:
    int id;
    double VisionDepthBias;
    double ForceConsumerTime;
    double VisionConsumerTime;
    bool Vaild;
    std::string datetime,ErrorMessage;

};


#endif //FORCEEIGENTEST_GLOBALVAR_H
